import fetch from '@/utils/request';

const API_GOODS_URL = '/api/user/product';
/**
 * 商品API对象
 * @module GoodsApi
 */
const GoodsApi = {
	/**
	 * 获取商品列表
	 *  query：查询参数对象
	 *  param：分页参数对象
	 */
	query: (query, param) => fetch.request({
		url: '/api/user/product/query',
		method: 'POST',
		data: {
			query: query,
			param: param
		},
	}),
	/**
	 * 获取店铺下商品列表
	 *  query：查询参数对象
	 *  param：分页参数对象
	 */
	query_tenant: (query, param) => fetch.request({
		url: '/api/user/product/query/tenant',
		method: 'POST',
		data: {
			query: query,
			param: param
		},
	}),
	/**
	 * 得到商品
	 * id：商品对象id
	 */
	get: (id) => fetch.request({
		url: '/api/user/product/get',
		method: 'POST',
		data: {
			id: id,
		},
	}),
	/**
	 * 得到商品详细信息
	 * id：商品对象sourceId，product.sourceId
	 */
	get_details: (id) => fetch.request({
		url: '/api/user/product/goods/get',
		method: 'POST',
		data: {
			id: id,
		},
	}),
	/**
	 * 获取收藏商品列表
	 *  query：查询参数对象
	 *  param：分页参数对象
	 */
	products: (query, param) => fetch.request({
		url: '/api/user/attention/products',
		method: 'POST',
		data: {
			query: query,
			param: param
		},
	}),
	/**
	 * 收藏商品
	 * attention：收藏商品对象
	 */
	attention_product: (attention) => fetch.request({
		url: '/api/user/attention/product',
		method: 'POST',
		data: {
			attention: attention,
		},
	}),
	/**
	 * 是否收藏商品
	 * attention：收藏商品对象
	 */
	is_attention: (attention) => fetch.request({
		url: '/api/user/attention/product/is',
		method: 'POST',
		data: {
			attention: attention,
		},
	}),
};


export default GoodsApi;
